/**
 * 
 * 问答页 
 * 
 */
class QuestionView extends BaseEuiView {
    private static exmlQ1Name: string = "QuestionStep1Skin";
    private static exmlQ2Name: string = "QuestionStep2Skin";
    private static exmlQ3Name: string = "QuestionStep3Skin";
    private static exmlQ4Name: string = "QuestionStep4Skin";
    private static exmlQ5Name: string = "QuestionStep5Skin";
    private static exmlQ6Name: string = "QuestionStep6Skin";

    private indexQuestion: number;

    public answerAView: eui.Button;
    public answerBView: eui.Button;
    public answerCView: eui.Button;
    public answerDView: eui.Button;
  

    public constructor(indexQuestion: number) {
        super();
        this.indexQuestion = indexQuestion;
        this.skinName = this.exml();
    }
    /**
     * 复写掉setSkinName代码
     */ 
    protected setSkinName(): void {
    }
    
    /**  emxl路径 */
    protected exml(): string {
        var exml: string = null;
        switch(this.indexQuestion) {
            case 0:
                exml = QuestionView.exmlQ1Name;
                break;
            case 1:
                exml = QuestionView.exmlQ2Name;
                break;
            case 2:
                exml = QuestionView.exmlQ3Name;
                break;
            case 3:
                exml = QuestionView.exmlQ4Name;
                break;
            case 4:
                exml = QuestionView.exmlQ5Name; 
                break;
            case 5:
                exml = QuestionView.exmlQ6Name;
                break;
            default:
                exml = QuestionView.exmlQ1Name;
                break;
        }
        Log.d("questionView exml:" + exml);
        return exml;
    }
    
    /** 初始化设置UI */
    protected initUI(): void {
        this.left = this.right = this.bottom = this.top = 0;
        Log.d(" this.answerAView:" + this.answerAView);
        this.answerAView.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickA,this);
        this.answerBView.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickB,this);
        this.answerCView.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickC,this);
        this.answerDView.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickD,this);
    }

    private clickA() {
        AppData.get.chooseA();
        this.openNextQuestion();
    }

    private clickB() {
        AppData.get.chooseB();
        this.openNextQuestion();
    }

    private clickC() {
        AppData.get.chooseC();
        this.openNextQuestion();
    }

    private clickD() {
        AppData.get.chooseD();
        this.openNextQuestion();
    }

    private openNextQuestion(){
        this.dispatchEventWith(CMDEvent.CHOOSE_ANSWER,false,this.indexQuestion+1);
    }
    
}
